package boddaert.philippe.cashGame.parser.page;

import java.util.HashMap;

import boddaert.philippe.cashGame.Site;

public class WebPageParserFactory {

	private static HashMap<Site, WebPageParser> parsers = new HashMap<Site, WebPageParser>();

	public static WebPageParser get(Site site) {
		if (site == null)
			throw new IllegalArgumentException();

		if (parsers.containsKey(site))
			return parsers.get(site);
		else {
			WebPageParser webPageParser = null;
			if (Site.DEUX_FOIS_MOINS_CHER.equals(site)) {
				webPageParser = new boddaert.philippe.cashGame.site.deuxfoismoincher.WebPageParser();
			} else if (Site.PRICEMINISTER.equals(site))
				webPageParser = new boddaert.philippe.cashGame.site.priceminister.WebPageParser();
			else
				webPageParser = new boddaert.philippe.cashGame.site.splitgames.WebPageParser();

			parsers.put(site, webPageParser);

			return webPageParser;
		}
	}
}
